package hotel.switchs.oversea.biz.controller;

import hotel.base.oversea.controller.BaseController;
import hotel.base.oversea.utils.Result;
import hotel.switchs.oversea.api.VO.request.CreateBasicRoomVo;
import hotel.switchs.oversea.biz.service.SwitchCreateBasicRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 携程房型效验
 * 携程创建房型接口
 * @Author lmf
 * @Date 2020/6/8 10:42
 **/
@Slf4j
@RestController
@RequestMapping("/switchCreateBasicRoom")
@Api(value = "SwitchCreateBasicRoomController",tags = {"携程效验房型"})
public class SwitchCreateBasicRoomController extends BaseController {


    @Autowired
    private SwitchCreateBasicRoomService switchCreateBasicRoomService;

    /**
     *  新增子物理房型
     *  根据子酒店id  母酒店id   母房型id
     */
    @PostMapping("/addBasicRoom")
    @ApiOperation(value = "新增子物理房型",notes = "必须经过oauth授权")
    public Result<Object> addBasicRoom(@RequestBody CreateBasicRoomVo createBasicRoomVo){
        log.info("=====进入创建子物理房型控制器=====");
        int[] masterBasicRoomIds=new int[1];
        if(createBasicRoomVo.getMasterBasicRoomId()==0){
            return new Result<>("母房型ID不能为空");
        }
        masterBasicRoomIds[0]=createBasicRoomVo.getMasterBasicRoomId();
        createBasicRoomVo.setMasterBasicRoomIds(masterBasicRoomIds);
        return switchCreateBasicRoomService.createBasicRoom(createBasicRoomVo);
    }


    /**
     * <H1>获取子酒店ID和子物理房型ID，定时器调用</H1>
     *
     * @param
     * @return hotel.base.oversea.utils.Result<java.lang.Object>
     * @author HuangT
     * @date 2020/7/14 14:49
    */
    @GetMapping("/getBasicRoomInfoForJob")
    public Result<Object> getBasicRoomInfo() {
        return switchCreateBasicRoomService.getBasicRoomInfoForJob();
    }

    /**
     * <H1>更新售卖状态</H1>
     *
     * @param
     * @return hotel.base.oversea.utils.Result<java.lang.Object>
     * @author HuangT
     * @date 2020/7/14 15:47
    */
    @PostMapping("/updateBasicRoomInfoForJob")
    public Result<Object> updateBasicRoomInfoForJob(@RequestBody CreateBasicRoomVo createBasicRoomVo) {
        return switchCreateBasicRoomService.updateBasicRoomInfoForJob(createBasicRoomVo);
    }

}
